class Solution {
public:
    int findMaxLength(vector<int>& nums) {
        int cnt = 0,ans = 0,n = nums.size();
        unordered_map<int,int> mm;
        mm[0] = -1;
        for(int i = 0;i < n;i++){
            if(nums[i] == 0){
                cnt--;
            }else{
                cnt++;
            }
            // if(mm.find(cnt) ==mm.end()){
            if(!mm.contains(cnt)){
                mm[cnt] = i;
            }else{
                ans = max(i - mm[cnt],ans);
            }
        }
        return ans;
    }
};






bool fun(vector<int>& arr1,vector<int>& arr2){
    return arr1[0] < arr2[0];
}
class Solution {
public:
    vector<vector<int>> merge(vector<vector<int>>& intervals) {
        sort(intervals.begin(),intervals.end(),fun);
        int l = intervals[0][0],r = intervals[0][0];
        vector<vector<int>> ret;
        for(auto& vec : intervals){
            if(vec[0] > r){
                ret.push_back({l,r});
                l = vec[0],r = vec[1];
            }else if(vec[1] > r){
                r = vec[1];
            }
        }

        ret.push_back({l,r});
        return ret;
    }
};